package com.itcast.springboot.waste_recovery.controller;


import com.itcast.springboot.response.SearchRes;
import com.itcast.springboot.waste_recovery.common.CommonResult;
import com.itcast.springboot.waste_recovery.common.CommonResultCode;
import com.itcast.springboot.waste_recovery.domain.WasteClassification;
import com.itcast.springboot.waste_recovery.domain.WasteData;
import com.itcast.springboot.waste_recovery.service.WasteClassificationService;
import com.itcast.springboot.waste_recovery.service.WasteDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 垃圾数据表 前端控制器
 * </p>
 *
 * @author 小破烂
 * @since 2020-08-19
 */
@RestController
@RequestMapping("/waste_recovery/waste-data")
@Api(tags = "垃圾数据表类接口")
public class WasteDataController {
    @Resource
    WasteDataService wasteDataService;

    @GetMapping("/customer/search/{waste_name}")
    @ApiOperation(value = "搜索")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "waste_name", value = "搜索废品关键字")
    })
    @RequiresPermissions("user-operated")       //拥有 user-operated 才可以访问
    public CommonResult search(@PathVariable(value = "waste_name") String wasteName){
        List<SearchRes> searchResList = wasteDataService.search(wasteName);
        return new CommonResult(CommonResultCode.CommonSuccess, searchResList);
    }

    @GetMapping("/staff/all")
    @ApiOperation(value = "废品信息")
    public CommonResult getWasteDatas(){
        List<WasteData> wasteDatas = wasteDataService.getWasteDatas();
        return new CommonResult(CommonResultCode.CommonSuccess, wasteDatas);
    }
}

